package com.github.manx98.okdownloader.common;

import org.jetbrains.annotations.NotNull;

import java.util.concurrent.ThreadFactory;

/**
 * 用于命名线程
 * @author : manx98
 * @date : 2021/5/26
 */
public class NameThreadFactory implements ThreadFactory {
    String threadName;

    public NameThreadFactory(String threadName) {
        this.threadName = threadName;
    }

    @Override
    public Thread newThread(@NotNull Runnable r) {
        Thread thread  = new Thread(r);
        thread.setName(threadName);
        return thread;
    }

}
